<%= paginate @loyalty_points_transactions %>

<% if @loyalty_points_transactions.present? %>
  <table class="loyalty-points-summary table table-striped table-hover">
    <thead class="thead-inverse">
    <tr>
      <th class="loyalty-points-date"><%= Spree.t(:date) %></th>
      <th class="loyalty-points-source"><%= Spree.t(:source) %></th>
      <th class="loyalty-points-source-id"><%= Spree.t(:source_reference) %></th>
      <th class="loyalty-points-comment"><%= Spree.t(:comment) %></th>
      <th class="loyalty-points-type"><%= Spree.t(:transaction_type) %></th>
      <th class="loyalty-points"><%= Spree.t(:loyalty_points) %></th>
      <th class="loyalty-points-balance"><%= Spree.t(:updated_balance) %></th>
    </tr>
    </thead>
    <tbody>
    <% @loyalty_points_transactions.each do |loyalty_point_transaction| %>
      <tr class="<%= cycle('even', 'odd') %>">
        <td class="loyalty-points-date"><%= pretty_time(loyalty_point_transaction.updated_at) %></td>
        <% if loyalty_point_transaction.source.present? %>
          <% transaction_source = loyalty_point_transaction.source_type.gsub('Spree::','') -%>
          <td class="loyalty-points-source"><%= transaction_source %></td>
          <% if transaction_source == "Order" %>
            <td class="loyalty-points-source-id"><%= link_to loyalty_point_transaction.source.number, spree.order_path(loyalty_point_transaction.source) %></td>
          <% else %>
            <td class="loyalty-points-source-id"><%= loyalty_point_transaction.source_id %></td>
          <% end %>
        <% else %>
          <td class="loyalty-points-source"></td>
          <td class="loyalty-points-source-id"></td>
        <% end %>
        <td class="loyalty-points-comment"><%= loyalty_point_transaction.comment %></td>
        <td class="loyalty-points-type"><%= loyalty_point_transaction.transaction_type %></td>
        <td class="loyalty-points"><%= loyalty_point_transaction.loyalty_points %></td>
        <td class="loyalty-points-balance"><%= loyalty_point_transaction.balance %></td>
      </tr>
    <% end %>
    </tbody>
  </table>
<% else %>
  <p><%= Spree.t(:you_have_not_earned_any_loyalty_points_yet) %></p>
<% end %>

<%= paginate @loyalty_points_transactions %>
